package com.DHH.Util;

import com.DHH.BikeAction.DHHRequest;
import com.DHH.Config.ApiConstant;
import com.DHH.Config.DHHConstant;
import com.DHH.Dto.SysSetting;
import com.DHH.Entity.Order.OrderInfo;
import com.DHH.wx.action.Pay_Refund;
import com.aliyuncs.exceptions.ClientException;
import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
import org.junit.Test;

import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by 汪玉东 on 2017/8/6.
 */
public class test {
    public  static  void main(String[] arges){
//        String code=String.valueOf((new Random().nextInt(8999) + 1000));
//        System.out.println(code);
        DHHRequest dhhRequest=new DHHRequest();
        dhhRequest.setCtl(DHHConstant.API_ctl_action2);
        dhhRequest.setUdid("357550110403760");
        System.out.println(dhhRequest.baseRequest());
//        DHHRequest dhhRequest1=new DHHRequest();
//        dhhRequest1.setCtl(DHHConstant.API_ctl_action3);
//        dhhRequest1.setUdid("357550110401410");
//        System.out.println(dhhRequest1.baseRequest());
    }

    @Test
        public  void  test1() throws ClientException {
//        PayDao payDao=new PayDao();
//       String rs= payDao.UserPayLaunchMoney("1000","dsfsd","okwIN0e5nXGrzUJ_i9mjSLGnV7ZM","127.0.0.1");
//        System.out.println(rs);
            //   Pay_Launch pay_launch=new Pay_Launch();
//        try {
//            pay_launch.doPost1("okwIN0e5nXGrzUJ_i9mjSLGnV7ZM","test","10");
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//        }
        Pay_Refund pay_launch=new Pay_Refund();
        Map map=pay_launch.postMap("2017101812573182650665","19900","19900");
        System.out.println(map.get("result_code"));
//        SMS.send("13896540677","1122");
//        String s="é\u0087\u008Dåº\u0086é\u0082®ç\u0094µå¤§å\u00AD¦ç§»é\u0080\u009Aå\u00AD¦é\u0099¢";
//        try {
//            String b3 = new String(s.getBytes("iso-8859-1"),"utf-8");
//            System.out.println(b3);
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//        }
    }

        @Test
        public  void  test2() throws ParseException {

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = sdf.parse("2017-09-21 11:53:37");
            Date date2 = sdf.parse("2017-09-21 13:54:15");

            OrderInfo orderInfo=new OrderInfo();
            orderInfo.setStartTime(date);
            orderInfo.setEndTime(date2);

            double mins =(int)Math.ceil((orderInfo.getEndTime().getTime() - orderInfo.getStartTime().getTime())/(1000 * 60.0));
           // Integer mins=(int)(121);
            System.out.println(mins);
//            System.out.println((float) (Math.ceil(mins/60.0))* ApiConstant.WX_D_PRICE);



           // System.out.println(Distance(106.55204594135284,28.564862743410746,106.55204594135284,29.564862743410746));
        }

    public static double Distance(double long1, double lat1, double long2,
                                  double lat2) {
        double a, b, R;
        R = 6378137; // 地球半径（米）
        lat1 = lat1 * Math.PI / 180.0;
        lat2 = lat2 * Math.PI / 180.0;
        a = lat1 - lat2;
        b = (long1 - long2) * Math.PI / 180.0;
        double d;
        double sa2, sb2;
        sa2 = Math.sin(a / 2.0);
        sb2 = Math.sin(b / 2.0);
        d = 2
                * R
                * Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(sa2)
                * Math.cos(lat2) * sb2 * sb2));
        return d;
    }






        @Test
        public  void tests1131123() throws Exception {
            //String value = GetValueByKey("Test.properties", "name");
            //System.out.println(value);
            //GetAllProperties("Test.properties");
            //loadConfig
            InputStream is=SourceLoader.class.getClassLoader().getSystemResourceAsStream("dhhConfig.properties");
            PropertiesUtil p=new PropertiesUtil();
            Map map=new HashMap();
            SysSetting apiConstant=ApiConstant.getSysSetting();
           /// MapToObj.MapToObj(apiConstant,SysSetting.class);
           p.WriteProperties(is,MapToObj.objectToMap(apiConstant));
        }





}
